---------------------------------------------------------------------------------------------------
IF (SELECT OBJECT_ID('[ServiceMemberManagement].[RanksFor]')) IS NOT NULL
BEGIN
	DROP PROCEDURE [ServiceMemberManagement].[RanksFor] 
END
---------------------------------------------------------------------------------------------------

GO
CREATE PROCEDURE [ServiceMemberManagement].[RanksFor]
@BranchOfServiceID BigInt 

AS 

---------------------------------------------------------------------------------------------------
--						Liberty
---------------------------------------------------------------------------------------------------
--  Stored Procedure :: GetAllMilitaryRanks
--                                                                            
---------------------------------------------------------------------------------------------------

SET NOCOUNT ON 

SELECT 
		mr.OID
		,types.Branch
		,mr.RankStructure
		,mr.Rank
		,mr.PayGrade
		,mr.Abbreviation
		,mr.Rank As Description
		,mr.DisplayOrder
		,types.OID As BranchOfServiceID
	FROM 
		dbo.MilitaryRanks mr INNER JOIN dbo.TypesOfMilitaryBranch types ON mr.BranchOfServiceID = types.OID
	WHERE 
		mr.Active = 1 
		And types.OID = @BranchOfServiceID       
	ORDER BY types.DisplayOrder, mr.DisplayOrder    

GO

---------------------------------------------------------------------------------------------------
-- Assign appropriate permissions
---------------------------------------------------------------------------------------------------
GRANT EXECUTE ON [ServiceMemberManagement].[RanksFor] TO [Liberty_Users]
GO

  